parent.$.fn.getIndex = function(){
    var $p=$(this).parent().children();
    return $p.index(this);
}
selectedPart = parent.$('#page_parts .ui-tabs-selected').getIndex();
wym = parent.$.wymeditors(selectedPart);
selectedBlock = wym.selected();
if (selectedBlock !== null) {
   $(selectedBlock).append('<%= escape_javascript(@html_for_wym) %>');
} else {
   wym.html(wym.html() + '<%= escape_javascript(@html_for_wym) %>');
}
wym.update();
close_dialog();
wym.close_dialog();